Skip to content

Conversation

@c-dilks
Copy link
Member

@c-dilks c-dilks commented Nov 24, 2025

Description

Changes:

  • convert SplitLogger into SplitLogManager
    • SplitLogger.create is replaced by SplitLogManager methods that override LogManager, such that Logger.getLogger and similar commands instantiate a logger that has the same properties as the old SplitLogger
    • it is now easy to swap to a different custom log manager

This is a much cleaner approach for controlling our logger; now all we need to do is:

  1. Use system property to choose a log manager
    • in this case, the new SplitLogManager, via a java CLI option:
      -Djava.util.logging.manager=org.jlab.logging.SplitLogManager
    • all bin/ scripts now use this option (via $JAVA_OPTS, see below)
  2. In your Java class, instantiate a Logger like normal:
    • just use Logger.getLogger, which will use the manager set by the java.util.logging.manager property:
      static final Logger logger = Logger.getLogger(MyClass.class.getName());

Log Levels

  • No changes in coatjava itself; see the 'Developer Notes', linked from the main README.md
  • Added log-level control to run-clara with new option -L
    • default level is INFO (-Linfo)
    • for example, -Loff to silence (mostly) everything, or -Lall for very verbose
    • option -q for quiet output is (mostly) unchanged

About $JAVA_OPTS

The environment variable $JAVA_OPTS is not used by the java command; rather it is a convention for things which wrap java. I added a default $JAVA_OPTS setting in libexec/env.sh that:

  • sets the log manager
  • prioritizes user's $JAVA_OPTS, if they have any
  • all java-calling bin/* scripts now use $JAVA_OPTS, but as the lowest priority in the CLI option ordering

Therefore, for all java-calling bin/* scripts, we have the following priority order of java options (from lowest priority to highest, i.e., left-to-right):

  1. $JAVA_TOOL_OPTIONS and _JAVA_OPTIONS: JVM options; we don't appear to use them here, but they are used by java at the lowest priority
  2. $JAVA_OPTS: includes the log manager choice (set in env.sh), followed by user's $JAVA_OPTS, if any
  3. hard-coded options unique to each bin/* script, such as -Xms and -Xmx
  4. some scripts allow for further override options, passed to the script as arguments to the right of -- (see env.sh's function split_cli); these will take the highest priority, since they are meant to be overrides

@baltzell baltzell added the java label Nov 25, 2025
@c-dilks c-dilks force-pushed the logman branch 2 times, most recently from 11f2b35 to 988c40b Compare November 26, 2025 01:58
@c-dilks c-dilks force-pushed the logman branch 2 times, most recently from 59fca7b to f3b34fd Compare December 11, 2025 14:53
@c-dilks c-dilks marked this pull request as ready for review December 16, 2025 21:02
@c-dilks
Copy link
Member Author

c-dilks commented Dec 16, 2025

@baltzell @raffaelladevita at long last this is ready. I confirm it also works well with clara.

However, clara's output logs aren't split to stderr/stdout, so I propose a fix for that too.

@c-dilks c-dilks merged commit 45bb53e into development Dec 18, 2025
40 checks passed
@c-dilks c-dilks deleted the logman branch December 18, 2025 22:49
c-dilks added a commit that referenced this pull request Dec 23, 2025
baltzell pushed a commit that referenced this pull request Dec 23, 2025
baltzell pushed a commit that referenced this pull request Dec 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants